import Vue from 'vue'
import Vuex from 'vuex'
import { allpaper } from '@/api/paper'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    imageList: [],
    total: 0,
    islogin:false
  },
  getters: {},
  mutations: {

    //图片
    getPapers(state,datas) { 
      state.imageList = datas.imgList
      state.total=datas.total
    },
    // 切换登录状态
    changeLoginStatus(state, flag) {
      state.islogin=flag
    }

  },
  actions: {
    // 获取壁纸
   async getPaper({commit},{current,size,sort,type}) {
      let res = await allpaper(current,size,sort,type)
      console.log(res)
      const data = {
        imgList: res.data.data.records,
        total:res.data.data.total
      }
      console.log(data.imgList)
      commit('getPapers',data)
    }
  },
  modules: {}
})
